//
//  MySelfViewController.m
//  RENTVISITOR
//
//  Created by wonder on 2017/8/21.
//  Copyright © 2017年 UNN. All rights reserved.
//

#import "MySelfViewController.h"
#import "LoginViewController.h"
#import "RentVieitor.h"
#import "SetViewController.h"
#import "SignContractViewController.h"
#import "SelfInformationViewController.h"
#import "SelectHouseViewController.h"
#import "PhoneViewController.h"
#import "AccounSafeViewController.h"
#import "FirstViewController.h"
#import "PublishSelectViewController.h"
#import "AuthStateViewController.h"
#import "SubscribeViewController.h"
#import "WaitReviewViewController.h"
#import "MJRefresh.h"

@interface MySelfViewController ()

@end

@implementation MySelfViewController {
    
    CGFloat heighY;
    UILabel *phoneLabel;
    UILabel *produceLabel;
    CALayer *MlineLayer11;
    UIButton *appleButton;
    NSString *statuStr;//判断申请经纪人状态
    NSString *reason;
    UIScrollView *_scrollView;
    NSString *type;
}



- (void)viewWillAppear:(BOOL)animated {
    
    self.navigationController.navigationBar.hidden = YES;
    self.tabBarController.tabBar.hidden = NO;
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:17],
       NSForegroundColorAttributeName:[Utils colorConvertFromString:@"#333333"]}];
    
    NSDictionary *dataDic = User_listsValue;
    
    if (dataDic != nil) {
    
        [self loadStateData];
        
    }
}

-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"logout" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"login" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"upName" object:nil];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    //接受退出登录通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logoutnotification) name:@"logout" object:nil];
    
    //接受退出登录通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginnotification) name:@"login" object:nil];
    
    //接受修改名字通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeNamenotification:) name:@"upName" object:nil];
    
    
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self _creatView];
    
    
    [self loadStateData];
    
}




- (void)_creatView {
    
    //创建滑动视图
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KWidth, KHeight-49)];
    _scrollView.backgroundColor = [UIColor whiteColor];
    [_scrollView resignFirstResponder];
    _scrollView.showsVerticalScrollIndicator = NO;
    _scrollView.userInteractionEnabled = YES;
    _scrollView.contentSize = CGSizeMake(KWidth, KHeight*1.5);
    _scrollView.bounces = YES;
    _scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
    [self.view addSubview:_scrollView];
    
    UIImageView *bgView2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, KWidth, 140)];
    bgView2.image = [UIImage imageNamed:@"bgimg"];
    [_scrollView addSubview:bgView2];
    


    UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    rightBtn.frame = CGRectMake(KWidth-30, 40, 20, 20);
    [rightBtn setBackgroundImage:[UIImage imageNamed:@"whiteSet"] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(setAction) forControlEvents:UIControlEventTouchUpInside];
    [_scrollView addSubview:rightBtn];
    
        //登录状态视图
    //1:已登录
    UIView *logYesView = [[UIView alloc] initWithFrame:CGRectMake(0, 70+35, KWidth, 70)];
    [_scrollView addSubview:logYesView];
    
    phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, KWidth-70, 25)];
    NSString *str;
    NSDictionary *dataDic = User_listsValue;
    if (dataDic != nil) {
        
        str = dataDic[@"name"];
        phoneLabel.userInteractionEnabled = NO;
    }else {
        str = @"登录/注册";
        phoneLabel.userInteractionEnabled = YES;
    }
    phoneLabel.text = str;
    phoneLabel.font = [UIFont systemFontOfSize:20];
    CGSize size = [str boundingRectWithSize:CGSizeMake(KWidth, 25) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:phoneLabel.font} context:nil].size;
    float  width = size.width;
    phoneLabel.textAlignment = NSTextAlignmentLeft;
    phoneLabel.textColor = [UIColor whiteColor];
    
    //添加手势
    UITapGestureRecognizer * PrivateLetterTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(loginAction)];
    PrivateLetterTap.numberOfTouchesRequired = 1; //手指数
    PrivateLetterTap.numberOfTapsRequired = 1; //tap次数
    [phoneLabel addGestureRecognizer:PrivateLetterTap];
    [logYesView addSubview:phoneLabel];
    
    //分割线
    MlineLayer11 = [CALayer layer];
    MlineLayer11.frame = CGRectMake(width+5+20 ,16.5, 1, 12);
    MlineLayer11.backgroundColor = [[UIColor whiteColor] CGColor];
    [logYesView.layer addSublayer:MlineLayer11];
    
    produceLabel = [[UILabel alloc] init];
    produceLabel.text = @"未认证经济人";
    produceLabel.frame = CGRectMake(width+10+20, 10, KWidth-70-width-10, 25);
    produceLabel.font = [UIFont systemFontOfSize:12];
    produceLabel.textAlignment = NSTextAlignmentLeft;
    produceLabel.textColor = [UIColor whiteColor];
    [logYesView addSubview:produceLabel];
    
    UIButton *editbtn = [UIButton buttonWithType:UIButtonTypeSystem];
    editbtn.frame = CGRectMake(20, 35, KWidth/2, 25);
    [editbtn setTitle:@"编辑个人资料" forState:UIControlStateNormal];
    editbtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [editbtn setTitleColor:[Utils colorConvertFromString:@"#666666"] forState:UIControlStateNormal];
    [logYesView addSubview:editbtn];
    [editbtn addTarget:self action:@selector(editAction) forControlEvents:UIControlEventTouchUpInside];
    editbtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    editbtn.titleEdgeInsets = UIEdgeInsetsMake(0,0, 0, 0);
    
    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(KWidth-65, 10, 50, 50)];
    imgView.image = [UIImage imageNamed:@"用户_我"];
    [logYesView addSubview:imgView];
    
    CALayer *MlineLayer = [CALayer layer];
    MlineLayer.backgroundColor = [[Utils colorConvertFromString:@"#efefef"] CGColor];
    MlineLayer.frame = CGRectMake(0 ,69, KWidth, 1);
    [logYesView.layer addSublayer:MlineLayer];
    
    //服务选项
    NSArray *titleArray = @[@"签订合同",@"看房预约",@"评价管理",@"售后服务"];
    for (int i=0; i<titleArray.count; i++) {
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(KWidth/4*i, 185, KWidth/4, 20)];
        label.text = @"0";
        label.font = [UIFont systemFontOfSize:14];
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor = [Utils colorConvertFromString:@"#333333"];
        [_scrollView addSubview:label];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.frame = CGRectMake(KWidth/4*i, 205, KWidth/4, 20);
        [button setTitle:titleArray[i] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:12];
        button.tag = 200+i;
        [button addTarget:self action:@selector(serveAction:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitleColor:[Utils colorConvertFromString:@"#333333"] forState:UIControlStateNormal];
        [_scrollView addSubview:button];
        
    }
    heighY = 235;
    
    //分割线
    CALayer *MlineLayer8 = [CALayer layer];
    MlineLayer8.backgroundColor = [[Utils colorConvertFromString:@"#efefef"] CGColor];
    MlineLayer8.frame = CGRectMake(0 ,heighY, KWidth, 0.5);
    [_scrollView.layer addSublayer:MlineLayer8];

    //申请经纪人
    UIImageView *applyView = [[UIImageView alloc] initWithFrame:CGRectMake(0, heighY+0.5, KWidth, KWidth*320/750)];
    applyView.userInteractionEnabled = YES;
    applyView.image = [UIImage imageNamed:@"img"];
    [_scrollView addSubview:applyView];
    
//    //添加手势
//    UITapGestureRecognizer * applyTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(applyTapAction:)];
//    applyTap.numberOfTouchesRequired = 1; //手指数
//    applyTap.numberOfTapsRequired = 1; //tap次数
//    [applyView addGestureRecognizer:applyTap];
    
    
    UILabel *appleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 15, KWidth-40, 25)];
    appleLabel.text = @"申请经纪人";
    appleLabel.font = [UIFont systemFontOfSize:20];
    appleLabel.textAlignment = NSTextAlignmentCenter;
    appleLabel.textColor = [Utils colorConvertFromString:@"#101010"];
    [applyView addSubview:appleLabel];
    
    UILabel *proLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 50, KWidth-40, 15)];
    proLabel.text = @"立即申请经纪人,随时掌握房源动态";
    proLabel.font = [UIFont systemFontOfSize:12];
    proLabel.textAlignment = NSTextAlignmentCenter;
    proLabel.textColor = [Utils colorConvertFromString:@"#666666"];
    [applyView addSubview:proLabel];
    
    appleButton = [UIButton buttonWithType:UIButtonTypeSystem];
    appleButton.frame = CGRectMake((KWidth-80)/2, 80, 80, 30);
    [appleButton setTitle:@"立即认证" forState:UIControlStateNormal];
    appleButton.titleLabel.font = [UIFont systemFontOfSize:12];
    [appleButton setTitleColor:[Utils colorConvertFromString:@"#666666"] forState:UIControlStateNormal];
    appleButton.layer.borderWidth = 1;
    [appleButton addTarget:self action:@selector(authenticationAction) forControlEvents:UIControlEventTouchUpInside];
    appleButton.layer.borderColor = [[Utils colorConvertFromString:@"#666666"] CGColor];
    appleButton.layer.cornerRadius = 2;
    [applyView addSubview:appleButton];
    

    
    heighY = heighY + KWidth*320/750;
    //分割线
    
    CALayer *MlineLayer14 = [CALayer layer];
    MlineLayer14.backgroundColor = [[Utils colorConvertFromString:@"#d0d0d0"] CGColor];
    MlineLayer14.frame = CGRectMake(0 ,heighY, KWidth, 1);
    [_scrollView.layer addSublayer:MlineLayer14];
    
    CALayer *MlineLayer2 = [CALayer layer];
    MlineLayer2.backgroundColor = [[Utils colorConvertFromString:@"#F2F2F2"] CGColor];
    MlineLayer2.frame = CGRectMake(0 ,heighY+1, KWidth, 10);
    [_scrollView.layer addSublayer:MlineLayer2];
    heighY = heighY + 21;
    
    //店铺相关
    UILabel *storeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, heighY, KWidth/2, 25)];
    storeLabel.text = @"店铺相关";
    storeLabel.font = [UIFont systemFontOfSize:15];
    storeLabel.textAlignment = NSTextAlignmentLeft;
    storeLabel.textColor = [Utils colorConvertFromString:@"#101010"];
    [_scrollView addSubview:storeLabel];
    heighY = heighY + 25;
    //分割线
    CALayer *MlineLayer3 = [CALayer layer];
    MlineLayer3.backgroundColor = [[Utils colorConvertFromString:@"#cfcfcf"] CGColor];
    MlineLayer3.frame = CGRectMake(20,heighY+15, KWidth-40, 0.5);
    [_scrollView.layer addSublayer:MlineLayer3];
    heighY = heighY + 0.5+15;
    
    NSArray *imgArray = @[@"icon_01",@"icon_02",@"icon_03",@"icon_04"];
    NSArray *storeArray = @[@"选择房源",@"店铺设置",@"店铺概况",@"房源分析"];
    for (int i=0; i<imgArray.count; i++) {
        
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake((KWidth/4-20)/2+KWidth/4*i, heighY+10, 20, 20)];
        imgView.image = [UIImage imageNamed:imgArray[i]];
        [_scrollView addSubview:imgView];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.frame = CGRectMake(KWidth/4*i, heighY+35, KWidth/4, 20);
        [button setTitle:storeArray[i] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:12];
        button.tag = 300+i;
        [button addTarget:self action:@selector(selectHouseAction:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitleColor:[Utils colorConvertFromString:@"#101010"] forState:UIControlStateNormal];
        [_scrollView addSubview:button];
    }
    heighY = heighY + 60;
    //分割线
    CALayer *MlineLayer4 = [CALayer layer];
    MlineLayer4.backgroundColor = [[Utils colorConvertFromString:@"#d0d0d0"] CGColor];
    MlineLayer4.frame = CGRectMake(20 ,heighY, KWidth-40, 0.5);
    [_scrollView.layer addSublayer:MlineLayer4];
    
    UIImageView *bgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, heighY+0.5, KWidth, KWidth*320/750)];
    bgView.userInteractionEnabled = YES;
    bgView.image = [UIImage imageNamed:@"img"];
    [_scrollView addSubview:bgView];
    
    UILabel *bgLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 15, KWidth-40, 25)];
    bgLabel.text = @"发布租房信息";
    bgLabel.font = [UIFont systemFontOfSize:20];
    bgLabel.textAlignment = NSTextAlignmentCenter;
    bgLabel.textColor = [Utils colorConvertFromString:@"#101010"];
    [bgView addSubview:bgLabel];
    
    UILabel *nLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 50, KWidth-40, 15)];
    nLabel.text = @"快速发布租房信息,随时掌握房源动态";
    nLabel.font = [UIFont systemFontOfSize:12];
    nLabel.textAlignment = NSTextAlignmentCenter;
    nLabel.textColor = [Utils colorConvertFromString:@"#666666"];
    [bgView addSubview:nLabel];
    
    UIButton *appButton = [UIButton buttonWithType:UIButtonTypeSystem];
    appButton.frame = CGRectMake((KWidth-80)/2, 80, 80, 30);
    [appButton setTitle:@"立即发布" forState:UIControlStateNormal];
    appButton.titleLabel.font = [UIFont systemFontOfSize:12];
    [appButton setTitleColor:[Utils colorConvertFromString:@"#666666"] forState:UIControlStateNormal];
    appButton.layer.borderWidth = 1;
    [appButton addTarget:self action:@selector(publishAction) forControlEvents:UIControlEventTouchUpInside];
    appButton.layer.borderColor = [[Utils colorConvertFromString:@"#666666"] CGColor];
    appButton.layer.cornerRadius = 2;
    [bgView addSubview:appButton];
    
    heighY = heighY + KWidth*320/750;
    
    //分割线
    CALayer *MlineLayer13 = [CALayer layer];
    MlineLayer13.backgroundColor = [[Utils colorConvertFromString:@"#d0d0d0"] CGColor];
    MlineLayer13.frame = CGRectMake(0 ,heighY, KWidth, 1);
    [_scrollView.layer addSublayer:MlineLayer13];
    
    CALayer *MlineLayer7 = [CALayer layer];
    MlineLayer7.backgroundColor = [[Utils colorConvertFromString:@"#F2F2F2"] CGColor];
    MlineLayer7.frame = CGRectMake(0 ,heighY+1, KWidth, 10);
    [_scrollView.layer addSublayer:MlineLayer7];
    
    heighY = heighY + 11;
    //选项视图
    CGFloat heigt = 50;
    NSArray *selectArray = @[@"我管理的房源",@"图片空间",@"个人信息",@"账号安全",@"联系客服"];
    for (int i=0; i<selectArray.count; i++) {
        
        UIView *selectView = [[UIView alloc] init];
        selectView.tag = 500+i;
        if (i<2) {
            
            selectView.frame = CGRectMake(0, heighY+heigt*i, KWidth, heigt);
            
        }else {
            
            selectView.frame = CGRectMake(0, heighY+heigt*i+10, KWidth, heigt);
        }
        //添加手势
        UITapGestureRecognizer * PrivateLetterTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAvatarView:)];
        PrivateLetterTap.numberOfTouchesRequired = 1; //手指数
        PrivateLetterTap.numberOfTapsRequired = 1; //tap次数
        [selectView addGestureRecognizer:PrivateLetterTap];
        [_scrollView addSubview:selectView];
        
        //店铺相关
        UILabel *selectLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, KWidth/2, 30)];
        selectLabel.text = selectArray[i];
        selectLabel.font = [UIFont systemFontOfSize:15];
        selectLabel.textAlignment = NSTextAlignmentLeft;
        selectLabel.textColor = [Utils colorConvertFromString:@"#101010"];
        [selectView addSubview:selectLabel];
        
        UIButton *selectButton = [UIButton buttonWithType:UIButtonTypeCustom];
        selectButton.frame = CGRectMake(KWidth-25, 20, 5, 10);
        [selectButton setBackgroundImage:[UIImage imageNamed:@"箭头-右"] forState:UIControlStateNormal];
        [selectView addSubview:selectButton];
        
        if (i==4) {
            
            UILabel *phoneLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(KWidth/2, 10, KWidth/2-40, 30)];
            phoneLabel1.text = @"4006--222222";
            phoneLabel1.font = [UIFont systemFontOfSize:12];
            phoneLabel1.textAlignment = NSTextAlignmentRight;
            phoneLabel1.textColor = [Utils colorConvertFromString:@"#666666"];
            [selectView addSubview:phoneLabel1];
        }
        //分割线
        CALayer *MlineLayer5 = [CALayer layer];
        MlineLayer5.backgroundColor = [[Utils colorConvertFromString:@"#cfcfcf"] CGColor];
        if (i == 1 || i== 4) {
            CALayer *MlineLayer12 = [CALayer layer];
            MlineLayer12.backgroundColor = [[Utils colorConvertFromString:@"#d0d0d0"] CGColor];
            MlineLayer5.backgroundColor = [[Utils colorConvertFromString:@"#F0F0F0"] CGColor];
            MlineLayer12.frame = CGRectMake(0 ,heigt-2, KWidth,1);
            MlineLayer5.frame = CGRectMake(0 ,heigt-1, KWidth,10);
            [selectView.layer addSublayer:MlineLayer12];
        }else {
             MlineLayer5.frame = CGRectMake(20 ,heigt-1, KWidth-40,1);
        }
       
        [selectView.layer addSublayer:MlineLayer5];
    }
    
    heighY = heighY + heigt*selectArray.count;
    _scrollView.contentSize = CGSizeMake(KWidth, heighY+20);
}

//下拉刷新
- (void)headerRefresh {
    
    [self loadStateData];
}

//获取审核状态
- (void)loadStateData {
    
    NSDictionary *dataDic = User_listsValue;
    if (dataDic == nil) {
        
        [_scrollView.mj_header endRefreshing];
        return;
    }
    NSString *url = [NSString stringWithFormat:@"%@agent/status",Main_Url];
    NSString *number = dataDic[@"number"];
    NSString *token = dataDic[@"token"];
    NSString *md5String = [NSString stringWithFormat:@"%@%@%@%@",number,token,APPKEY_URL,url];
    //32位小写
    md5String = [LCMD5Tool MD5ForLower32Bate:md5String];
    NSDictionary *param = @{
                            @"number":number,
                            @"token":token,
                            @"sign":md5String
                            };
    [AFHttpTool requestWihtUrl:url params:param success:^(id response) {
        
        [_scrollView.mj_header endRefreshing];
        if ([response[@"code"] isEqualToString:@"10000"]) {
            
            [self reloadStateData:response[@"data"]];
            
            
        }else {
            
           
        }
        
        
    } failure:^(NSError *err) {
        
         [APPDELEGATE showPro:@"获取经纪人状态失败"];
         [_scrollView.mj_header endRefreshing];
        
    }];
}

- (void)reloadStateData:(NSDictionary *)dic {
    
    NSString *status = dic[@"status"];
    statuStr = dic[@"status"];
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:status forKey:@"status"];
    if ([status isEqualToString:@"1"]) {
        
        [appleButton setTitle:@"等待审核" forState:UIControlStateNormal];
    }
    
    if ([status isEqualToString:@"2"]) {
        
        [appleButton setTitle:@"通过审核" forState:UIControlStateNormal];
        produceLabel.text = @"已认证经纪人";
    }

    if ([status isEqualToString:@"3"]) {
        
        [appleButton setTitle:@"未通过审核" forState:UIControlStateNormal];
        reason = dic[@"reason"];
        type = dic[@"type"];
        
    }

    
//    UIButton *appleButton
}


- (void)tapAvatarView:(UIGestureRecognizer *)recognizer {
    
    NSDictionary *dataDic = User_listsValue;
    
    if (recognizer.view.tag == 500) {
        [APPDELEGATE showPro:@"功能完善中"];
    }else if (recognizer.view.tag == 501){
        [APPDELEGATE showPro:@"功能完善中"];
    }else if (recognizer.view.tag == 502){

        //个人信息
        if (dataDic != nil) {
            
            SelfInformationViewController *selfVc = [[SelfInformationViewController alloc] init];
            [self.navigationController pushViewController:selfVc animated:YES];
            
        }else {
            
            LoginViewController *loginVc = [[LoginViewController alloc] init];
            [self presentViewController:loginVc animated:YES completion:nil];
            
        }
        
    }else if (recognizer.view.tag == 503){
        
        
        //个人信息
        if (dataDic != nil) {
            
            //账号安全
            AccounSafeViewController *safeVc = [[AccounSafeViewController alloc] init];
            [self.navigationController pushViewController:safeVc animated:YES];

            
        }else {
            
            LoginViewController *loginVc = [[LoginViewController alloc] init];
            [self presentViewController:loginVc animated:YES completion:nil];
            
        }
        
    }else if (recognizer.view.tag == 504){
        [APPDELEGATE showPro:@"功能完善中"];
    }
}

//设置
- (void)setAction {
    
    self.navigationController.navigationBar.hidden = NO;
    SetViewController *setVc = [[SetViewController alloc] init];
    [self.navigationController pushViewController:setVc animated:YES];
    
}

//编辑个人资料
- (void)editAction {
    
    NSDictionary *dataDic = User_listsValue;
    
    if (dataDic != nil) {
        
        SelfInformationViewController *selfVc = [[SelfInformationViewController alloc] init];
        [self.navigationController pushViewController:selfVc animated:YES];
        
    }else {
        
        LoginViewController *loginVc = [[LoginViewController alloc] init];
        [self presentViewController:loginVc animated:YES completion:nil];
        
    }
    
    
    
}

- (void)selectHouseAction:(UIButton *)button {
    
    [APPDELEGATE showPro:@"功能完善中"];
    
    if (button.tag == 300) {
        
//        //选择房源
//        SelectHouseViewController *selectVc = [[SelectHouseViewController alloc] init];
//        [self.navigationController pushViewController:selectVc animated:YES];
        
    }else if(button.tag == 301) {
        
       
        
    }else if(button.tag == 302) {
        
        //评价管理
        
    }else if(button.tag == 303) {
        
        //售后服务
        
    }
}

//服务选项
- (void)serveAction:(UIButton *)button {
    
    if (button.tag == 200) {
        
        [APPDELEGATE showPro:@"功能完善中"];
//        //签订合同
//        self.navigationController.navigationBar.hidden = NO;
//        SignContractViewController *signVc = [[SignContractViewController alloc] init];
//        [self.navigationController pushViewController:signVc animated:YES];
        
    }else if(button.tag == 201) {
        
        //看房预约
        SubscribeViewController *selectVc = [[SubscribeViewController alloc] init];
        [self.navigationController pushViewController:selectVc animated:YES];
        
    }else if(button.tag == 202) {
        
        //评价管理
        
    }else if(button.tag == 203) {
        
        //售后服务
        
    }
}

//退出登录通知
- (void)logoutnotification {
    
    NSString *str = @"登录/注册";
    phoneLabel.text = str;
    phoneLabel.userInteractionEnabled = YES;
    CGSize size = [str boundingRectWithSize:CGSizeMake(KWidth, 25) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:phoneLabel.font} context:nil].size;
    CGFloat width = size.width;
    phoneLabel.text = str;
    MlineLayer11.frame = CGRectMake(width+5+20 ,16.5, 1, 12);
    produceLabel.frame = CGRectMake(width+10+20, 10, KWidth-70-width-10, 25);
    [appleButton setTitle:@"立即验证" forState:UIControlStateNormal];
}

//登录通知
- (void)loginnotification {
    
    NSDictionary *dataDic = User_listsValue;
    CGSize size = [dataDic[@"name"] boundingRectWithSize:CGSizeMake(KWidth, 25) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:phoneLabel.font} context:nil].size;
    phoneLabel.userInteractionEnabled = NO;
    CGFloat width = size.width;
    phoneLabel.text = dataDic[@"name"];
    MlineLayer11.frame = CGRectMake(width+5+20 ,16.5, 1, 12);
    produceLabel.frame = CGRectMake(width+10+20, 10, KWidth-70-width-10, 25);
    
    [self loadStateData];
}

- (void)changeNamenotification:(NSNotification *)notification {
    
    NSString *nameStr = notification.userInfo[@"name"];
    CGSize size = [nameStr boundingRectWithSize:CGSizeMake(KWidth, 25) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:phoneLabel.font} context:nil].size;
    phoneLabel.userInteractionEnabled = NO;
    CGFloat width = size.width;
    phoneLabel.text = nameStr;
    MlineLayer11.frame = CGRectMake(width+5+20 ,16.5, 1, 12);
    produceLabel.frame = CGRectMake(width+10+20, 10, KWidth-70-width-10, 25);
    
}
//登录
- (void)loginAction {
    
    self.navigationController.navigationBar.hidden = NO;
    LoginViewController *loginVc = [[LoginViewController alloc] init];
    [self presentViewController:loginVc animated:YES completion:nil];
}

#pragma mark -- 发布租房信息
- (void)publishAction {
    
    NSDictionary *dataDic = User_listsValue;
    
    if (dataDic == nil) {
        
        LoginViewController *loginVc = [[LoginViewController alloc] init];
        [self presentViewController:loginVc animated:YES completion:nil];
        return;
    }

//    [APPDELEGATE showPro:@"功能完善中"];
    PublishSelectViewController *pubVc = [[PublishSelectViewController alloc] init];
    
    [self.navigationController pushViewController:pubVc animated:YES];
    
}



#pragma mark --经济人认证
- (void)authenticationAction {
    
    NSDictionary *dataDic = User_listsValue;
    
    if (dataDic == nil) {
        
        LoginViewController *loginVc = [[LoginViewController alloc] init];
        [self presentViewController:loginVc animated:YES completion:nil];
        return;
    }
    
    AuthStateViewController *rentVc = [[AuthStateViewController alloc] init];
    WaitReviewViewController *waitVc = [[WaitReviewViewController alloc] init];
    //1为等待审核，2为已通过审核，3为未通过审核
    if ([statuStr isEqualToString:@"1"]) {
        
        [self.navigationController pushViewController:waitVc animated:YES];
        return;
    }
    
    if ([statuStr isEqualToString:@"2"]) {
        
        rentVc.iscuccess = YES;
        [self.navigationController pushViewController:rentVc animated:YES];
        return;
    }
    
    if ([statuStr isEqualToString:@"3"]) {
        
        rentVc.iscuccess = NO;
        rentVc.reason = reason;
        rentVc.type = type;
        [self.navigationController pushViewController:rentVc animated:YES];
        return;
    }
    
//    [APPDELEGATE showPro:@"功能完善中"];
    FirstViewController *firstVc = [[FirstViewController alloc] init];
    [self.navigationController pushViewController:firstVc animated:YES];
}


@end
